library global;
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';


class Profile {
  String user = '';
  bool isdark = false;

  //  头像
  String avatar = '';
  //  昵称
  String nickName = '';


  Profile();

  Profile.fromJson(Map json) {
    isdark = json['isdark'];

  }

  Map<String, dynamic> toJson() => {
    'user': user,
    'isLogin': isdark,
    'avatar': avatar,
    'nickName': nickName
  };
}
class Global {
  static SharedPreferences _prefs;
  static Profile profile = Profile();

  static  Future   isDark() async {

    SharedPreferences prefs = await SharedPreferences.getInstance();
    int a=prefs.getInt("dark")??0;
    if(a==1){
      return true;
    }else{
      return false;
    }

  }

  static saveProfile() => _prefs.setString('profile', jsonEncode(profile.toJson()));

}
